package com.charzhan.seven;

import com.charzhan.utiles.rabbitmqutil;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.nio.charset.StandardCharsets;

public class reciveLogTopicc1 {
    public static final String EXCHANGE_ANME= "topic_logs";
    public static void main(String[] args)  throws  Exception{
        Channel channel = rabbitmqutil.getChannel();
        channel.exchangeDeclare(EXCHANGE_ANME, BuiltinExchangeType.TOPIC);
        String queName="q1";
        //durable 持久化
        channel.queueDeclare(queName,false,false,false,null);
        channel.queueBind(queName,EXCHANGE_ANME,"*.orange.*");
        System.out.println("wait for message ......");
        DeliverCallback deliverCallback=(tag,message)->{
            System.out.println(new String(message.getBody(),"utf-8"));
            System.out.println(queName+":--->"+message.getEnvelope().getRoutingKey());
        };
        channel.basicConsume(queName,true,deliverCallback,consumerTag -> {});


    }
}
